<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="法人代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frdm">
              <a-input v-model="model.frdm" placeholder="请输入法人代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="报表代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bbdm">
              <a-input v-model="model.bbdm" placeholder="请输入报表代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjrq">
              <a-input v-model="model.sjrq" placeholder="请输入数据日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="指标类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zblx">
              <a-input v-model="model.zblx" placeholder="请输入指标类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="指标名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbmc">
              <a-input v-model="model.zbmc" placeholder="请输入指标名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="比重(%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input-number v-model="model.bz" placeholder="请输入比重(%)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期余额(面值)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bqjemz">
              <a-input-number v-model="model.bqjemz" placeholder="请输入本期余额(面值)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上期余额(面值)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sqjemz">
              <a-input-number v-model="model.sqjemz" placeholder="请输入上期余额(面值)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="环比增减(面值)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hbzjmz">
              <a-input-number v-model="model.hbzjmz" placeholder="请输入环比增减(面值)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="跨期校验(面值)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kqjymz">
              <a-input-number v-model="model.kqjymz" placeholder="请输入跨期校验(面值)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期余额(余额)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bqjeye">
              <a-input-number v-model="model.bqjeye" placeholder="请输入本期余额(余额)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="浮动比例(余额)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fdblye">
              <a-input-number v-model="model.fdblye" placeholder="请输入浮动比例(余额)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上期余额(余额)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sqyeye">
              <a-input-number v-model="model.sqyeye" placeholder="请输入上期余额(余额)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="余额增减(余额)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yezjye">
              <a-input-number v-model="model.yezjye" placeholder="请输入余额增减(余额)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="本期利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bqll">
              <a-input-number v-model="model.bqll" placeholder="请输入本期利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上期利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sqll">
              <a-input-number v-model="model.sqll" placeholder="请输入上期利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数据生成日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjscrq">
              <a-input v-model="model.sjscrq" placeholder="请输入数据生成日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cjr">
              <a-input v-model="model.cjr" placeholder="请输入创建人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属机构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ssjg">
              <a-input v-model="model.ssjg" placeholder="请输入所属机构"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="报送批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bspc">
              <a-input v-model="model.bspc" placeholder="请输入报送批次"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="报表主题" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bbzt">
              <a-input v-model="model.bbzt" placeholder="请输入报表主题"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="指标类型码值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zblxmz">
              <a-input v-model="model.zblxmz" placeholder="请输入指标类型码值"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="指标名称码值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbmcmz">
              <a-input v-model="model.zbmcmz" placeholder="请输入指标名称码值"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'BuPBalCheckInfForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/balCheck/buPBalCheckInf/add",
          edit: "/balCheck/buPBalCheckInf/edit",
          queryById: "/balCheck/buPBalCheckInf/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>